package com.CityHunter.Activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.SlidingDrawer;
import android.widget.AdapterView.OnItemClickListener;

import com.CityHunter.R;
import com.CityHunter.Activity.MenuAct.ItemClickListener;
import com.CityHunter.Adapter.MenuGridViewAdapter;
import com.CityHunter.MapActivity.CreateSchedulePage;
import com.CityHunter.MapActivity.RouteMapView;

public class WelcomePage extends Activity{
	
	private int[] icons = { R.drawable.favb, R.drawable.clock,
			R.drawable.groupofusers, R.drawable.mail, R.drawable.find,
			R.drawable.web ,R.drawable.network,R.drawable.infoabout};
	
	private String[] titles = { "Myfavourite", "Schedule", "Friend",
			"Buddy", "Search", "WhatNearMe" ,"Track","Help"};
	
	private GridView gv;
	private SlidingDrawer sd;
	private ImageView im;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.welcome_page);
		
		gv = (GridView)findViewById(R.id.contentGrid);
		sd = (SlidingDrawer)findViewById(R.id.menuSlider);
		im = (ImageView)findViewById(R.id.menuSwitchIcon);
		
		// Use customize menu adapter
		MenuGridViewAdapter adapter = new MenuGridViewAdapter(this,titles,icons);
		gv.setAdapter(adapter);
		
		sd.setOnDrawerOpenListener(new SlidingDrawer.OnDrawerOpenListener(){
			@Override
			public void onDrawerOpened(){
				im.setImageResource(R.drawable.close);
			}
		});
		
		sd.setOnDrawerCloseListener(new SlidingDrawer.OnDrawerCloseListener(){
			@Override
			public void onDrawerClosed(){
				im.setImageResource(R.drawable.open);
			}
		});
		
		gv.setOnItemClickListener(new ItemClickListener());
	}
	
	class ItemClickListener implements OnItemClickListener {
		public void onItemClick(AdapterView<?> av, View v, int index,
				long arg3) {

			Intent i = null;
			if (index == 1)
				 i = new Intent(WelcomePage.this, CreateSchedulePage.class);
			else if (index==2)
				 i = new Intent(WelcomePage.this, GroupView.class);
			else if (index==3)
				 i = new Intent(WelcomePage.this, BuddyPage.class);
			else if (index == 5)
				i = new Intent(WelcomePage.this,RouteMapView.class);
			else if (index==6)
				 i = new Intent(WelcomePage.this, TrackAct.class);
			
			if (i != null)
				startActivity(i);
			
		}

	}
	
}
